package bb.lanxing.wxapi;

import com.tencent.mm.opensdk.modelbase.BaseReq;
import com.tencent.mm.opensdk.modelbase.BaseResp;
import com.tencent.mm.opensdk.modelmsg.ShowMessageFromWX;
import com.tencent.mm.opensdk.modelmsg.WXAppExtendObject;
import com.umeng.socialize.utils.SLog;
import com.umeng.socialize.weixin.view.WXCallbackActivity;

import android.os.Bundle;
import android.text.TextUtils;

import bb.lanxing.util.Log;
import bb.lanxing.util.jsbridge.BridgeUtil;

public class WXEntryActivity extends WXCallbackActivity {
    @Override 
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        Log.d("WXEntryActivity onCreate === ");
    }

    @Override 
    protected void onResume() {
        super.onResume();
        Log.d("WXEntryActivity onResume === ");
    }

    @Override 
    protected void onPause() {
        super.onPause();
        Log.d("WXEntryActivity onPause === ");
    }

    @Override 
    public void onReq(BaseReq baseReq) {
        if (baseReq.getType() == 4) {
            String str = ((WXAppExtendObject) ((ShowMessageFromWX.Req) baseReq).message.mediaObject).extInfo;
            if (!TextUtils.isEmpty(str) && str.startsWith("lushu_")) {
                try {
                    redirectRouteInfo(Long.parseLong(str.split(BridgeUtil.UNDERLINE_STR)[1]));
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            finish();
            return;
        }
        super.onReq(baseReq);
    }

    @Override 
    public void onResp(BaseResp baseResp) {
        SLog.I("WXCallbackActivity 分发回调");
        super.onResp(baseResp);
    }

    private void redirectRouteInfo(long j) {
//        Intent intent = new Intent(this, RouteInfoActivity.class);
//        intent.putExtra("lushu_server_id", j);
//        startActivity(intent);
    }
}
